﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml.Serialization;
using System.Runtime.Serialization;
using System.Xml.Linq;

namespace Woodbase.CodeBase.WVR.Objects
{
    [Serializable()]
    [XmlType("Actor", Namespace = "http://ns.woodbase.dk/Movies.xsd")]
    public class Actor : ISerializable
    {
        [XmlAttribute("given-name")]
        public string GivenName
        {
            get;
            set;
        }


        [XmlAttribute("last-name")]
        public string LastName
        {
            get;
            set;
        }

        [XmlAttribute("nationality")]
        public string Nationality { get; set; }

        [XmlAttribute("birth-year")]
        public int BirthYear
        {
            get;
            set;
        }

        [XmlAttribute("gender")]
        public Gender Sex
        {
            get;
            set;
        }

        [XmlAttribute("character-name")]
        public string CharacterName { get; set; }

        public string FullName { get{return GivenName + " " + LastName;}  }

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            throw new NotImplementedException();
        }

        public XElement ToXml()
        {
            XNamespace ns = XNamespace.Get("http://ns.woodbase.dk/Movies.xsd");
            XElement x = new XElement(ns + "actor",
                                new XAttribute("givenName", GivenName),
                                new XAttribute("lastName", LastName),
                                new XAttribute("birthYear", BirthYear),
                                new XAttribute("male", (Sex == Gender.MALE) ? true : false),
                                new XAttribute("nationality", Nationality)
                                );
            return x;
        }
    }

    public enum Gender
    {
        MALE,
        FEMALE
    }
}